Categorical Monads and Computer Programming

نویسندگان

  • Nick Benton
  • NICK BENTON
چکیده

The categorical notion of monad was first introduced into computer science as a way of structuring mathematical models of programming languages. The idea has subsequently been transferred back into computing practice, influencing the design of widely-used languages and frameworks. Expressions in conventional imperative programming languages bear a superficial similarity to conventional mathematical notation, but they behave quite differently. For example, if f and g are both ‘functions’ or ‘methods’ that take an integer argument and return an integer result (we say they have type int -> int and write f : int -> int), the two expressions f(3) + g(4) and g(4) + f(3) are not generally equivalent, as they would be if f and g were ordinary mathematical functions. The issue is not that integer addition in programming languages is not commutative (it almost always is), but that calling a ‘function’ can do many things as well as, or instead of, computing a result depending solely on the arguments. And the order and multiplicity of these ‘other things’ – which are called side-effects – affect the behaviour of one’s program. The ability to perform input/output operations is one example of a side-effect. If, say, both f and g just return their argument, but also print it to the screen, then the expressions will both have value 7, but we would see “34” printed in the first case, and “43” in the second, assuming that the operands of addition are evaluated left-to-right. Another ubiquitous side-effect is mutable state. If the definitions (in C-like syntax) were

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Distributing probability over non-determinism

We study the combination of probability and nondeterminism from a categorical point of view. In category theory, nondeterminism and probability are represented by suitable monads. Those two monads do not combine well, as they are. To overcome this problem we introduce the notion of indexed valuations. This notion is used to define a new monad that can be combined with the usual nondeterministic...

متن کامل

Operads as Polynomial 2-monads

In this article we give a construction of a polynomial 2-monad from an operad and describe the algebras of the 2-monads which then arise. This construction is different from the standard construction of a monad from an operad in that the algebras of our associated 2-monad are the categorified algebras of the original operad. Moreover it enables us to characterise operads as categorical polynomi...

متن کامل

Monads and Modular Term Rewriting

Monads can be used to model term rewriting systems by generalising the well-known equivalence between universal algebra and monads on the category Set. In [Lü96], this semantics was used to give a purely categorical proof of the modularity of confluence for the disjoint union of term rewriting systems. This paper provides further support for monadic semantics of rewriting by giving a categorica...

متن کامل

Polynomial and Analytic Functors and Monads, revisited

We describe an abstract 2-categorical setting to study various notions of polynomial and analytic functors and monads.

متن کامل

Dijkstra and Hoare monads in monadic computation

The Dijkstra and Hoare monads have been introduced recently for capturing weakest precondition computations and computations with preand post-conditions, within the context of program verification, supported by a theorem prover. Here we give a more general description of such monads in a categorical setting. We first elaborate the recently developed view on program semantics in terms of a trian...

متن کامل

A Survey of Categorical Computation: Fixed Points, . . .

E. Moggi, Categories of Partial Morphism and the p -calculus, In Category Theory and Computer Programming, Lecture Notes in Computer Science 240, SpringerVerlag, 1986. [Mog88a] E. Moggi, Computational Lambda-Calculus and Monads, Technical Report ECSLFCS-88-66, University of Edinburgh, October, 1988. [Mog88b] E. Moggi, Partial Morphisms in Categories of E ective Objects, Information and Computat...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2015